feat(opentelemetry) add @temporalio/interceptors-opentelemetry-v2#1951
feat(opentelemetry) add @temporalio/interceptors-opentelemetry-v2#1951chris-olszewski wants to merge 3 commits intoolszewski/break_up_buildfrom
Conversation
3039377 to
99e880b
Compare
|
Since you are making a breaking v2 version, could you also align the The Example: |
| clientInterceptors: { | ||
| workflow: [new OpenTelemetryWorkflowClientInterceptor(interceptorOptions)], | ||
| }, | ||
| workerInterceptors: { |
There was a problem hiding this comment.
We need to add nexus interceptors
| export * from './worker'; | ||
| export { | ||
| OpenTelemetryWorkflowClientInterceptor, | ||
| /** deprecated: Use OpenTelemetryWorkflowClientInterceptor instead */ |
There was a problem hiding this comment.
You can get rid of that legacy thing.
| * | ||
| * @experimental Plugins is an experimental feature; APIs may change without notice. | ||
| */ | ||
| export class OpenTelemetryPlugin extends SimplePlugin { |
There was a problem hiding this comment.
Are we not injecting bundler options?
Btw, we now have a preloadedModules bundler option, which may help reduce the overhead associated with per-workflow loading of the OpenTelemetry library.
| * @module | ||
| */ | ||
| export { inWorkflowContext, proxySinks, workflowInfo, AsyncLocalStorage, ContinueAsNew } from '@temporalio/workflow'; | ||
| export { alea, type RNG } from '@temporalio/workflow/lib/alea'; |
There was a problem hiding this comment.
Use the new random streams api once it has landed.
| @@ -0,0 +1,54 @@ | |||
| import type { IdGenerator } from '@opentelemetry/sdk-trace-base'; | |||
| import { alea, type RNG } from './workflow-imports'; | |||
There was a problem hiding this comment.
Use the new Random Streams API, once it has landed.
What was changed
Add a package to provide interceptors that support OpenTelemetry v2.
First commit is a straight copy of the v1 with package bumps and the necessary changes the came along with those bumps.
Note: Histories created with the
@temporalio/interceptors-opentelemetrywill not be compatible with@temporalio/interceptors-opentelemetryand vice-versa. The crux of the issue is that OpenTelemetry changed their usage ofMath.random(). The random number generator was shared by OpenTelemetry for generating span ids as well as theuuidfunction which is used for generating child workflow ids. This can cause NDE. To prevent future breakages from changes toMath.randomusage, we now provide anIdGeneratorto OpenTelemetry that uses its own random number generator. This doesn't offer a huge amount of value as we are still vulnerable to changes to the amount of calls toMath.randomoutside of id creation, but it does offer protection if the number of ids created changes.Due to histories already being incompatible, I removed the yield point injections from the interceptors to have a cleaner starting point.
Why?
This was done in a separate package to allow us to support both v1 and v2 without forcing users to upgrade.
Checklist
Closes [Feature Request] Add support for opentelemetry v2 #1658
How was this tested:
Copied over relevant tests and added an additional test to verify that replaying workflow history that has uuid call doesn't trigger NDE in the future.
Any docs updates needed?